
layui.use('table',function(){


     $ = layui.jquery;
    var table = layui.table;



    //用户列表
    var tableIns=table.render({

        elem: '#complaint',
        url : '/sharepark/platform/allComplaint',
        page : true,
        height : "full-100",
        limits : [10,20,30,40],
        limit : 10,
        id : "complaint",
        text:{none:'暂无相关数据'},
        cols : [[
            {type: "checkbox", fixed:"left", width:50},
            {field: 'coId', title: '投诉信息编号', sort:true, align:"center"},
            {field: 'outUId', title: '被投诉方', align:'center',templet: '<div>{{d.beingComplaint.uName}}</div>' },
            {field: 'inUId', title: '投诉方', align:'center',templet: '<div>{{d.toComplaint.uName}}</div>'},
            {field: 'coReason', title:'投诉理由', align:'center'},
            {field: 'coTime', title: '投诉时间', sort:true, align:'center'},
            {field: 'coFlag', title: '处理状态', sort:true, align:'center'},
            {title: '操作', minWidth:150, templet:'#complaintListBar',fixed:"right",align:"center"}
        ]]
    });

    //监听行工具事件
    table.on('tool(complaint)', function(obj){
        var data = obj.data;


        if (obj.event ==='edit'){
            if (data.coFlag ==='已处理'){

                layer.alert("该投诉已处理完成", {icon: 2});
            }else{
                layer.confirm('确定处理该投诉吗？',{icon:3},function () {
                    var param = data.coId;

                    $.post("/sharepark/platform/setComplaint","id="+param,function (res) {
                        layer.msg(res.msg);
                        if (res.msg ==='处理成功'){
                            tableIns.reload();
                        }
                    })
                });
            }
        }
    });


    //搜索
    $(".search_btn").on("click",function(){

        tableIns.reload({
            where: {
                "coFlag": $('#coFlag').val()
            }
            ,page: {
                curr: 1 //重新从第 1 页开始
            }
        });

    });




})
